# 作业：
# 1、做一个学生点名系统，系统里支持：存入学生、更改学生、删除学生、点到学生姓名方法
#
# 存入学生（姓名、年龄、家庭地址、手机号）： 存入成功后，提示xxx存入成功
# 更改学生（姓名、年龄、家庭地址、手机号）：可以修改学生内容的任意一个字段
# 删除学生：删除的学生将不在展示
# 展示全部学生：可以看到全部的学生姓名
# 点到学生姓名：随机抽取任意一个存在的学生信息，然后打印：到！。举例： 刘闯到！
#
# 以上内容，需要连接数据库，每次的数据都需要增、删、改、查去做
#
# student表：name、age、address、phone_number
#
# import pymysql
# class student():
#     def __init__(self,host,user,password,databases,cursorclass = None):
#         self.host = host
#         self.user = user
#         self.password = password
#         self.databases = databases
#         self.cursorclass = cursorclass
#     def connect(self):
#         self.db = pymysql.connect(host=self.host,user=self.user,password=self.password,
#                                   database=self.databases,cursorclass=self.cursorclass)
#         self.cursor = self.db.cursor()
#     def close(self):
#         self.cursor.close()
#         self.db.close()
#     def select_one(self,sql):
#         self.connect()
#         try:
#             self.cursor.execute(sql)
#             result = self.cursor.fetchone()
#             self.close()
#         except Exception as e:
#             print("select error %s" % e)
#             result = None
#         return result
#     def select_all(self,sql):
#         self.connect()
#         try:
#             self.cursor.execute(sql)
#             result = self.cursor.fetchall()
#             self.close()
#         except Exception as e:
#             print("select error %s" % e)
#             result = None
#         return result
#     def __edit(self,sql):
#         self.connect()
#         try:
#             self.cursor.execute(sql)
#             self.db.commit()
#             result = "数据库更新成功"
#         except:
#             result = "数据库更新失败"
#         return result
#     def insert(self,sql):
#         return self.__edit(sql)
#     def delete(self,sql):
#         return self.__edit(sql)
#     def update(self,sql):
#         return self.__edit(sql)
#     def random(self):
#         import random
#
#         randoms = "SELECT name FROM student ORDER BY RAND() LIMIT 1"
#
#         result = student1.select_one(randoms)
#
#         if result:
#             name = result["name"]
#             print(name + "到！")
#         else:
#             print("学生信息不存在")
#
#
# student1 = student(host="120.46.172.68",user="root",password="123456"
#                    ,databases="test",cursorclass=pymysql.cursors.DictCursor)

# print(student1.insert("insert into student(id,name,age,address,phone_number) "
#                       "values(3,'刘门',88,'厕所',13838381438);"))
# print(student1.update("update student set age = 50 where age = 88;"))
# print(student1.delete("delete from student where id = 1;"))
# print(student1.select_all("select * from student;"))
# print(student1.select_all("select name from student;"))
# student1.random()


# 2、点餐管理系统
# 1》、餐馆可以新增菜品、下架菜品、修改菜品
# 2》、每个菜品，都有对应的库存，所有菜品的库存均为999，每出一道菜，库存-1
# 菜品有对应的价格，餐厅老板定义价格每道菜不允许超过15元，没有小数单位，均为整数
# 3》、餐馆后台有点赞系统，能够收集客户对菜品的喜好，0~5分
# 4》、有菜品评分提报功能，对平均分数（菜品总分/打分人数）低于3分的菜品进行强制下架；
#
#
# 客户端
# perper = 0 类属性
# 总分= 0
# 1》、客户可以进行点餐 调用父类
# 2》、每个客户的起始钱包均为200，订餐后扣减对应金额
# 3》、可以为每个菜进行打分

